<template>
  <el-dialog
    top="80px"
    :visible.sync="isVisible"
    :title="'监控设备 ＞详情'"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <el-container>
      <el-main
        :style="{ 'max-height': maxHeightDialog }"
        class="container-main"
      >
        <el-row>
          <el-col :span="12">
            <t-detail
              v-if="dataList.length != 0"
              :list="dataList"
              :is-card-border="true"
            >
              <template
                v-if="item.value != ''"
                slot="createdTime"
                slot-scope="{ item }"
              >
                {{ item.value | datefmt('YYYY-MM-DD HH:mm:ss') }}
              </template>
              <template
                v-if="item.value != ''"
                slot="updatedTime"
                slot-scope="{ item }"
              >
                {{ item.value | datefmt('YYYY-MM-DD HH:mm:ss') }}
              </template>
            </t-detail>
          </el-col>
          <el-col :span="12" style="padding-left: 20px; padding-top: 8px">
            <div style="position: relative; height: 400px">
              <iframe
                :src="players.videoUrl"
                frameborder="0"
                style="width: 100%; height: 100%"
                allowfullscreen
                allow="autoplay; fullscreen; microphone;"
              ></iframe>
            </div>
          </el-col>
        </el-row>
      </el-main>
      <el-footer>
        <el-button
          size="medium"
          icon="el-icon-close"
          style="width: 120px"
          @click="isVisible = false"
        >
          关闭
        </el-button>
      </el-footer>
    </el-container>
  </el-dialog>
</template>
<script>
import TDetail from '@/components/TDetail'
import dataDetailMixins from '@/mixins/data-detail-mixins'
import LivePlayer from '@liveqing/liveplayer'
export default {
  components: {
    TDetail,
    LivePlayer,
  },
  mixins: [dataDetailMixins],
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '',
    },
    params: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  data() {
    return {
      dataList: this.getDetailList(),
      players: {
        serial: '',
        code: '',
        // videoUrl: this.params.streamUrl, // process.env.VUE_APP_VIDEO_API + 'uploads/image/vidio/222.mp4',
        videoUrl: this.params.streamUrl,
        // `<iframe
        //           :src="${}"
        //           height="360px"
        //           width="100%"
        //           allowfullscreen
        //           allow="autoplay; fullscreen; microphone;"
        //         ></iframe>`,
        protocol: '',
        poster: '', // 视频封面图片 String default ''
        bLoading: true, // 指示加载状态, 支持 sync 修饰符
        bCloseShow: true,
        bControls: true, // 显示播放器控制栏 Boolean default true
        bSmart: true,
        bFullscreen: true,
        closeTimer: 0,
        device_id: '',
        device_name: '',
      },
    }
  },
  computed: {
    isVisible: {
      get() {
        return this.dialogVisible
      },
      set() {
        this.toClose()
      },
    },
  },
  methods: {
    getDetailList() {
      console.log(this.params)
      const list = [
        [{ text: '设备编码', value: this.params.cameraCode || '-' }],
        [{ text: '设备名称', value: this.params.cameraName || '-' }],
        // [{ text: '监控设备品牌', value: this.params.cameraBrand || '-' }],
        [{ text: '所在位置：', value: this.params.cameraLocation || '-' }],
        [{ text: 'rtsp流地址', value: this.params.rtsp || '-' }],
        [{ text: 'http流地址', value: this.params.streamUrl || '-' }],
        [{ text: 'ip地址', value: this.params.cameraIp || '-' }],

        [{ text: '所属部门', value: this.params.deptName || '-' }],
        [{ text: '所属网格', value: this.params.gridName || '-' }],

        [
          {
            text: '创建时间',
            value: this.params.createdTime,
            slotName: 'createdTime',
          },
        ],
        [
          {
            text: '更新时间：',
            value: this.params.updatedTime,
            slotName: 'updatedTime',
          },
        ],
      ]
      return list
    },
    toClose() {
      this.$emit('close')
    },
  },
}
</script>
